/**
 * 
 */
package org.swing.utility.jai.bean;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
/**
 * @author Quynh Nhu
 *
 */
public class Location {
	  private String address;

	  private String area;

	  private String continent;

	  private String countryName;

	  private Country country;

	  private String description;

	  private String id;

	  private String location;

	  private String place;

	  private String placeArea;

	  private String postalCode;

	  private String region;

	  private String subArea;

	  private PropertyChangeSupport notifier = new PropertyChangeSupport(this);

	  public Location() {
	  }

	  public Location(final String description, final String address,
	    final String postalCode, final String location, final String placeArea,
	    final String place, final String subArea, final String area,
	    final String region, final Country country, final String continent) {
	    this.description = description;
	    this.address = address;
	    this.postalCode = postalCode;
	    this.location = location;
	    this.placeArea = placeArea;
	    this.place = place;
	    this.subArea = subArea;
	    this.area = area;
	    this.region = region;
	    this.country = country;
	    if (country != null) {
	      this.countryName = country.getName();
	    }
	    this.continent = continent;
	  }

	  public Location(final Location location) {
	    this.description = location.description;
	    this.address = location.address;
	    this.postalCode = location.postalCode;
	    this.location = location.location;
	    this.placeArea = location.placeArea;
	    this.place = location.place;
	    this.subArea = location.subArea;
	    this.area = location.area;
	    this.region = location.region;
	    this.country = location.country;
	    this.countryName = location.countryName;
	    this.continent = location.continent;
	  }

	  public synchronized void addPropertyChangeListener(
	    final PropertyChangeListener listener) {
	    notifier.addPropertyChangeListener(listener);
	  }

	  public synchronized void addPropertyChangeListener(final String propertyName,
	    final PropertyChangeListener listener) {
	    notifier.addPropertyChangeListener(propertyName, listener);
	  }

	  public synchronized void removePropertyChangeListener(
	    final PropertyChangeListener listener) {
	    notifier.removePropertyChangeListener(listener);
	  }

	  public synchronized void removePropertyChangeListener(
	    final String propertyName, final PropertyChangeListener listener) {
	    notifier.removePropertyChangeListener(propertyName, listener);
	  }

	  /**
	   * @return
	   */
	  public String getAddress() {
	    return address;
	  }

	  /**
	   * @return
	   */
	  public String getArea() {
	    return area;
	  }

	  /**
	   * @return
	   */
	  public String getContinent() {
	    return continent;
	  }

	  /**
	   * @return
	   */
	  public String getCountryName() {
	    return countryName;
	  }

	  /**
	   * @return
	   */
	  public Country getCountry() {
	    return country;
	  }

	  /**
	   * @return
	   */
	  public String getDescription() {
	    return description;
	  }

	  /**
	   * @return
	   */
	  public String getId() {
	    return id;
	  }

	  /**
	   * @return
	   */
	  public String getLocation() {
	    return location;
	  }

	  /**
	   * @return
	   */
	  public String getPlace() {
	    return place;
	  }

	  /**
	   * @return
	   */
	  public String getPlaceArea() {
	    return placeArea;
	  }

	  /**
	   * @return
	   */
	  public String getPostalCode() {
	    return postalCode;
	  }

	  /**
	   * @return
	   */
	  public String getRegion() {
	    return region;
	  }

	  /**
	   * @return
	   */
	  public String getSubArea() {
	    return subArea;
	  }

	  /**
	   * @param string
	   */
	  public void setAddress(final String address) {
	    Object oldValue = this.address;
	    this.address = address;
	    notifier.firePropertyChange("address", oldValue, address);
	  }

	  /**
	   * @param string
	   */
	  public void setArea(final String area) {
	    Object oldValue = this.area;
	    this.area = area;
	    notifier.firePropertyChange("area", oldValue, area);
	  }

	  /**
	   * @param string
	   */
	  public void setContinent(final String continent) {
	    Object oldValue = this.continent;
	    this.continent = continent;
	    notifier.firePropertyChange("continent", oldValue, continent);
	  }

	  /**
	   * @param string
	   */
	  public void setCountryName(final String countryName) {
	    Object oldValue = this.countryName;
	    this.countryName = countryName;
	    if (oldValue != countryName) {
	      setCountry(Country.getCountryByName(countryName));
	      notifier.firePropertyChange("countryName", oldValue, countryName);
	    }
	  }

	  /**
	   * @param string
	   */
	  public void setCountry(final Country country) {
	    Object oldValue = this.country;
	    this.country = country;
	    if (oldValue != country) {
	      if (country != null) {
	        setCountryName(country.getName());
	      } else {
	        setCountryName(null);
	      }
	      notifier.firePropertyChange("country", oldValue, country);
	    }
	  }

	  /**
	   * @param string
	   */
	  public void setDescription(final String description) {
	    Object oldValue = this.description;
	    this.description = description;
	    notifier.firePropertyChange("description", oldValue, description);
	  }

	  /**
	   * @param long1
	   */
	  public void setId(final String id) {
	    Object oldValue = this.id;
	    this.id = id;
	    notifier.firePropertyChange("id", oldValue, id);
	  }

	  /**
	   * @param string
	   */
	  public void setLocation(final String location) {
	    Object oldValue = this.location;
	    this.location = location;
	    notifier.firePropertyChange("location", oldValue, location);
	  }

	  /**
	   * @param string
	   */
	  public void setPlace(final String place) {
	    Object oldValue = this.place;
	    this.place = place;
	    notifier.firePropertyChange("place", oldValue, place);
	  }

	  /**
	   * @param string
	   */
	  public void setPlaceArea(final String placeArea) {
	    Object oldValue = this.placeArea;
	    this.placeArea = placeArea;
	    notifier.firePropertyChange("placeArea", oldValue, placeArea);
	  }

	  /**
	   * @param string
	   */
	  public void setPostalCode(final String postalCode) {
	    Object oldValue = this.postalCode;
	    this.postalCode = postalCode;
	    notifier.firePropertyChange("postalCode", oldValue, postalCode);
	  }

	  /**
	   * @param string
	   */
	  public void setRegion(final String region) {
	    Object oldValue = this.region;
	    this.region = region;
	    notifier.firePropertyChange("region", oldValue, region);
	  }

	  /**
	   * @param string
	   */
	  public void setSubArea(final String subArea) {
	    Object oldValue = this.subArea;
	    this.subArea = subArea;
	    notifier.firePropertyChange("subArea", oldValue, subArea);
	  }

	}
